{extend name="./oscshop/admin/view/public/base.html" /}
{block name="content"}
<div class="page-header">
	<h1>	
		{$breadcrumb1}
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$breadcrumb5}
		</small>
	</h1>
</div>

<form action="{:url('programme/end_voucher')}" method="get">
	<table class="table table-striped table-bordered table-hover search-form">
		<thead>
		<tr>
			<th>
				<input name="username" type="number" placeholder="输入用户名" value="{:input('param.username')}" />
				<input name="sub_date" type="date" placeholder="输入用户名" value="{:input('param.sub_date')}" />
				&nbsp;&nbsp;
				<select name="exchange_id" id ="exchange_id"   tabindex="4">
					<option value ="">请选择交易所</option>
					{volist name="exchange" id="p" empty="$exchange"}
					<option value ="{$p.id}" {if condition="$p.id eq input('param.exchange_id')"} selected="selected" {/if}>{$p.name}</option>
					{/volist}
				</select>

				<select name="variety_id" id ="variety_id"   tabindex="4">
					<option value ="">请选择交易品种</option>
				</select>&nbsp;&nbsp;&nbsp;
				<button class="btn btn-primary">查询</button>&nbsp;&nbsp;&nbsp;
				<a href="{:url('programme/end_voucher')}" class="btn btn-primary">清空查询条件</a>
				&nbsp;&nbsp;&nbsp;
			</th>
		</tr>
		</thead>
	</table>
</form>
<form id="myForm" action="{:url('programme/end_voucher')}" method="post">
	<div class="row">
		<div class="col-xs-12">
			<div class="table-responsive">
				<span>申请总金额：{$sum}</span><p></p>
				<table id="con_table" class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th><input type="checkbox" id="all1" value="1" /></th>
							<th>ID</th>
							<th>用户</th>
							<th>姓名</th>
							<th>交易所</th>
							<th>交易品种</th>
							<th>金额</th>
							<th>申请时间</th>
							<th>凭证提交时间</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						{volist name="list" id="v"}
						<tr>
							<td><input type="checkbox" name="{$v.id}"   id="list" value="{$v.id}" /></td>
							<td>{$v.id}</td>
							<td>{$v.username}</td>
							<td>{:get_member_idcardname($v.username)}</td>
							<td>{:get_trade_name($v.exchange_id)}</td>
							<td>{:get_variety_name($v.variety_id)}</td>
							<td>{$v.num}</td>
							<td>{$v.sub_date}</td>
							<td>{$v.vou_date}</td>
							<td>
								<a class="btn btn-primary" href='{:url("programme/end_voucher_info",array("id"=>$v["id"]))}'>审核操作</a>
							</td>
						</tr>
						{/volist}
					</tbody>

				</table>
			</div>
			{$page}
		</div>
	</div>
</form>
{/block}
{block name="javascript"}
<script>
	function topLeft(id){
		var judge = prompt("审批意见");
		if(judge){
			window.location.href = "repulse?id="+id+"&desc="+judge;
		}
	}

	$(function(){
	   	$(".search").click(function () {
			var url = $(this).attr('url');
			var query = $('.search-form').find('input,select').serialize();
			query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
			query = query.replace(/^&/g, '');
			if (url.indexOf('?') > 0) {
				url += '&' + query;
			} else {
				url += '?' + query;
			}
//		   	alert(url);
			window.location.href = url;
		});
	});

	$(function(){
		$(".batch").click(function () {
			//alert('test');
			var r = confirm("确认是否批量审核");
			if(r==false)
			{
				return;
			}
			document.getElementById("myForm").submit()

		});
	});
	$("#all1").change(function() {

		var chk = this.checked;

		var ck_list = $("#con_table").find("input[type='checkbox']");

		var len = ck_list.length;
		//alert(len);
		for (var i = 0; i < len; i++) {
			if (chk == false) {
				ck_list[i].checked = false;

			}
			else {
				ck_list[i].checked = true;
			}
		}
	});
</script>

<script type="text/javascript">
	$('#exchange_id').change(function(){
		var iframe_array = <?php echo  json_encode($variety);   ?>;
		var checkValue=jQuery("#exchange_id").val();
		$("#variety_id").empty();
		for (var i = 0; i <iframe_array.length ; i++)
		{
			if(iframe_array[i]['exchange_id']==checkValue)
			{
				var opt = "<option value='"+iframe_array[i]['id']+"'>"+iframe_array[i]['name']+"</option>";
				jQuery("#variety_id").append(opt);
			}
		}

	})
</script>
{/block}